package com.yayan.xh.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Map;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import com.yayan.xh.bean.OperateBean;

public class OperateDao extends ConnectionBase implements IOperateDao {

	private Connection conn = null;
	
	private QueryRunner qRunner = null;
	
	private PreparedStatement ps = null;
	
	private ResultSet rsKey = null;
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public OperateBean adminLogin(Map<String, String> map) throws Exception{
		OperateBean result = null;
		try {
			qRunner = new QueryRunner();
			String sql = "select * from tb_operate where op_username=? and op_password=?";
			conn = getConn();
			result =  (OperateBean) qRunner.query(conn, sql, new BeanHandler(OperateBean.class), map.get("username"), map.get("password"));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			close(conn, ps, rsKey);
		}
		return result;
	}


}
